package main

import (
	"fmt"
	"math/rand"
	"time"
)

func main() {
	homework1()
	homework2()
	homework3()

}
func homework1() {
	// 打印九九乘法表
	for i := 1; i <= 9; i++ {
		for j := 1; j <= i; j++ {
			fmt.Print(j, " * ", i, " = ", i*j, "\t")
		}
		fmt.Println()
	}

}

func homework2() {
	// 随机生成20以内的20个非0正整数，打印出来。对生成的数值，第单数个（不是索引）累加求和，第偶数个累乘求积。打印结果
	r := rand.New(rand.NewSource(time.Now().UnixNano()))

	var nums [20]int
	summation := 0
	multiplication := 1

	for i := 0; i < 20; i++ {
		nums[i] = r.Intn(20) + 1
	}

	for j := 0; j < len(nums); j++ {
		if j%2 != 0 {
			// 基数行
			summation += nums[j]
		} else {
			// 偶数行
			multiplication *= nums[j]
		}
	}
	fmt.Println("打印随机数", nums)
	fmt.Println("打印求和", summation)
	fmt.Println("打印求积", multiplication)
}

func homework3() {
	// 打印100以内的斐波那契数列
	// 从第3项开始，每一项都等于前两项的和；递推方式定义
	// ？

}
